package com.ys.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.ys.web.entity.OriginBaidu;
import com.ys.web.pojo.BaiduPromoteInfo;
import com.ys.web.pojo.CompanyInfo;
import com.ys.web.pojo.VisitAccessKeywordDay;
import com.ys.web.service.CompanyService;

/**
 * 查询行业关键词
 * @author wdj
 *
 */
@Scope("prototype")
@Controller
@RequestMapping("/industryKeywordController")
public class IndustryKeywordController {
	
	@Autowired
	private CompanyService companyService;

	/**
	 * 跳传页面
	 * @param httpServletRequest
	 * @return
	 */
	@RequestMapping(params="showIndustryKeyword")
	public ModelAndView showIndustryKeyword(HttpServletRequest httpServletRequest){		
		return new ModelAndView("industryKeyword/industryKeywordList");		
	}	
	
	/**
	 * 按行业查询公司(只显示有百度数据查看的公司)
	 * @param page 当前页码
	 * @param industryId 行业id
	 * @return 公司列表
	 */
	@RequestMapping(params="getCompanyByIndustryPage")
	@ResponseBody
	public List<CompanyInfo> getCompanyByIndustryPage(Integer page, String industryId) {
		//暂时页面没传分页码
//		Integer page_par = 1;
//		if(page!=null){
//			page_par = page;
//		}
//		Integer industryId_par = null;
//		if(industryId!=null && industryId.length()>0) {
//			industryId_par = Integer.valueOf(industryId);
//		}
		
//		return companyService.getCompanyByIndustry(industryId_par, page_par);
		
		return companyService.getCompanyByIndustry_ws(industryId);
	}
	
	/**
	 * 按行业查询关键词(百度数据)
	 * @param industryId 行业id
	 * @return 百度关键词列表
	 */
	@RequestMapping(params="getKeyInfoByIndustry")
	@ResponseBody
	public List<BaiduPromoteInfo> getKeyInfoByIndustry(HttpServletRequest request) {
		String industryId = request.getParameter("industryId");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		return companyService.getKeyInfoByIndustryBd(industryId,startTime,endTime);
	}
	
	/**
	 * 按行业查询关键词(易数宝数据)
	 * @param industryId 行业id
	 * @return 易数宝关键词列表
	 */
	@RequestMapping(params="getKeyInfoByIndustryYsb")
	@ResponseBody
	public List<VisitAccessKeywordDay> getKeyInfoByIndustryIdYsb(HttpServletRequest request) {
		String industryId = request.getParameter("industryId");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		List<VisitAccessKeywordDay> ysbKeywordByIndustryId = companyService.getYsbKeywordByIndustryId(industryId,startTime,endTime);
		return ysbKeywordByIndustryId;
	}
	
}
